cmake_minimum_required(VERSION 2.6)
project(backtrace)

set(CMAKE_BUILD_TYPE Debug)

if (${CMAKE_SIZEOF_VOID_P} MATCHES "8")
    set(BUILD_FLAGS "-Wno-deprecated -D_LIBC_REENTRANT -Wall -D_FILE_OFFSET_BITS=64")
    set(LIBRARY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/lib/x64")
    set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/bin/x64")
else()
    set(BUILD_FLAGS "-Wno-deprecated -D_LIBC_REENTRANT -Wall")
    set(LIBRARY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/lib/x86")
    set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/bin/x86")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} ${BUILD_FLAGS} -O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} ${BUILD_FLAGS} -O2")

include_directories("${PROJECT_SOURCE_DIR}/include")

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    set(TARGET_NAME "${PROJECT_NAME}_d")
    set(TEST_NAME "test_${PROJECT_NAME}_d")
else()
    set(TARGET_NAME "${PROJECT_NAME}")
    set(TEST_NAME "test_${PROJECT_NAME}")
endif ()

add_subdirectory("${PROJECT_SOURCE_DIR}/bt")
add_subdirectory("${PROJECT_SOURCE_DIR}/test")
